<script setup>
import { ref } from 'vue'
const src = ref('')
function handleChange(e) {
  console.log(e.target.files[0])
  console.log(e.target.files)
  const file = e.target.files[0]
  const reader = new FileReader()
  reader.readAsDataURL(file)
  reader.onload = () => {
    src.value = reader.result
  }
}
</script>

<template>
  <div>
    <div>perview-image</div>
    <input type="file" @change="handleChange" />
    <div>预览图片</div>
    <img v-if="src" :src="src" alt="" />
  </div>
</template>

<style lang="scss" scoped></style>
